package com.baidu.shop.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Description:
 * @ClassName: MrSwagger2Config
 * @Author: User
 * @date: 2020.10.21 11:48
 * @version: 1.0
 */
@Configuration
@EnableSwagger2
public class MrSwagger2Config{
        @Bean
        public Docket createRestApi(){
            return new Docket(DocumentationType.SWAGGER_2)
                    .apiInfo(this.apiInfo())
                    .select()
                    .apis(RequestHandlerSelectors.basePackage("com.baidu"))
                    .paths(PathSelectors.any())
                    .build();
        }

        private ApiInfo apiInfo(){
            return new ApiInfoBuilder()
                    //标题
                    .title("明瑞SWAGGER2标题")
                    //条款地址
                    .termsOfServiceUrl("http://www.baidu.com")
                    //联系方式-->有String参数的方法但是已经过时，所以不推荐使用
                    .contact(new Contact("wanghao","baidu.com","wanghao@qq.com"))
                    //版本
                    .version("v1.0")
                    //项目描述
                    .description("描述")
                    //创建API基本信息
                    .build();
        }
}
